import {Component} from "@angular/core";
import {ActionSheetController, ToastController, ViewController} from "ionic-angular";
import {Common} from "../../../../providers/common";
/**
 * Created by s-wangh on 2017/11/13.
 */
@Component({
  selector: 'stock-search',
  templateUrl: 'stock-search.html'
})
export class StockSearchPage {
  public recommendKey: string = '';        //推荐人
  public minEndDate: string = '';          //可选的最小日期
  public maxDate: string = '';             //可选的最大日期
  public startDate: string = '';           //开始时间
  public endDate: string = '';             //结束时间
  public status: string = '全部';          //金股状态
  constructor(public viewCtrl: ViewController, public common: Common, public toastCtrl: ToastController, public actionSheetCtrl: ActionSheetController) {
    this.maxDate = this.common.getNowFormatDate();
  }

  ionChange() {
    this.minEndDate = this.startDate;
  }

  /**
   * 关闭对话框
   */
  cancel() {
    this.viewCtrl.dismiss("close");
  }

  /**
   * 清空查询条件
   */
  clear() {

  }

  selectEndTime() {
    if (this.startDate == null || this.startDate == '') {
      let toast = this.toastCtrl.create({
        message: '请先选择开始时间',
        duration: 3000
      });
      toast.present();
      return;
    }
  }
  /**
   *切换金股状态
   */
  presentActionSheet() {
    let actionSheet = this.actionSheetCtrl.create({
      // title: '请选择状态',
      buttons: [
        {
          text: '全部',
          // role: 'destructive',
          handler: () => {
            console.log('Destructive clicked');
          }
        },{
          text: '结束',
          // role: 'destructive',
          handler: () => {
            this.status='结束';
          }
        },{
          text: '未结束',
          handler: () => {
            this.status='未结束'
          }
        },{
          text: '取消',
          role: 'cancel',
          handler: () => {
          }
        }
      ]
    });
    actionSheet.present();
  }
}
